package com.zw.jdbc.controller;

import com.zw.jdbc.dao.UserDao;
import com.zw.jdbc.model.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;

/**
 * Created by lovez on 2016/11/19.
 */
@Controller
@RequestMapping("/auth")
public class UserController {

    @Autowired
    UserDao userDao;

    @ResponseBody
    @RequestMapping(value = "/login",method = RequestMethod.GET)
    public String login(@Valid UserEntity userEntity) {
        if (null == userDao.query(userEntity)) {
            return "name or password error";
        }
        return "welcome Spring boot world";
    }
}
